package fauxman.ClydeStates;

import java.awt.Point;

import fauxman.BlinkyStates.ChaseBlinkyState;
import fauxman.DynamicElements.Ghost;
import fauxman.model.WorldModel;
import fauxman.utilities.SpriteUtil;

public class ChaseClydeState extends ClydeState {
	private static ChaseClydeState instance;
	
	private ChaseClydeState(){
	}
	
	public static ChaseClydeState getInstance(){
		if (instance==null)
			instance = new ChaseClydeState();
		return instance;
	}

	public void setAppearance(int appearanceID, Ghost g) {
		g.setAppearance(SpriteUtil.getClydeSprite(appearanceID));
	}

	@Override
	public int[] getTarget(WorldModel model, Ghost g) {
		int[] target = null;
		Point fmPosition = model.getFauxman().getDiscretePosition();
		Point gPosition = g.getDiscretePosition();
		double currentDiff = Math.sqrt(( Math.pow(fmPosition.x - gPosition.x, 2) + Math.pow(fmPosition.y - gPosition.y, 2)));
		if(currentDiff >= 8.0){
			target = new int[2];
			target[0] = fmPosition.x;
			target[1] = fmPosition.y;
		}
		else{
			target = ScatterClydeState.getInstance().getTarget(model, g);
		}
		return target;
	}
}
